''''
描述：创建一个session,使用session自动管理cookie。
'''''

import requests

s = requests.session()
print("登陆之前：", s.cookies)

url = "http://192.168.65.1:8000/api/user/login"
cs2 = {"userName": "admin", "password": "123456", "remember": False}
r = s.post(url, json=cs2)
print("登陆之后：", s.cookies)
print(r.text)
assert r.json()['message'] == '成功'
assert r.json()['code'] == 1


url = "http://192.168.65.1:8000/api/admin/education/subject/page"
cs = {"level": None, "pageIndex": 1, "pageSize": 10}
r = s.post(url, json=cs)
print(r.text)
assert r.json()['message'] == '成功'
assert r.json()['code'] == 1

url = "http://192.168.65.1:8000/api/user/logout"
r = s.post(url)
print(r.text)
assert r.json()['message'] == '成功'
assert r.json()['code'] == 1
print("退出登录之后：", s.cookies)